/* ===================================================================
 * Copyright (C) 2024 Hefei Jiushao Intelligent Technology Co., Ltd.
 * All rights reserved.
 *
 * This software is licensed under the GNU Affero General Public License
 * v3.0 (AGPLv3.0) or a commercial license. You may choose to use this
 * software under the terms of either license.
 *
 * For more information about the AGPLv3.0 license, please visit:
 * https://www.gnu.org/licenses/agpl-3.0.html
 * For licensing inquiries or to obtain a commercial license, please
 * contact Hefei Jiushao Intelligent Technology Co., Ltd.
 * ===================================================================
 * Author: JasonChen
 */

#ifndef FILE_UTIL_H
#define FILE_UTIL_H

#include <string>
#include <vector>
#ifndef CXX_LESS_17
#include <filesystem>
#else
#include <dirent.h>
#include <unistd.h>
#endif
#include "common/constant.h"


AMCAX_EXCHANGE_NAMESPACE_BEGIN 
namespace FileUtil 
{
    std::string GetFilenameWithoutExtension(const std::string &path) ;
    std::string GetExtension(const std::string &path);
    bool IsFileExist(const std::string &path) ;
    bool IsPathExist(const std::string &path) ;
    bool IsDirExist(const std::string &path);
    #ifndef CXX_LESS_17
    void TraverseDirectory(const std::filesystem::path &path, std::vector<std::string> *containers);
    #else
    void TraverseDirectory(const std::string& path, std::vector<std::string> *containers);
    bool RemoveDir(const std::string& path) ;
    void MakeDir(const std::string &path) ;
    #endif

    #ifndef CXX_LESS_17
    #else
        std::string GetParentPath(const std::string& path) ;

    #endif
}

AMCAX_EXCHANGE_NAMESPACE_END

#endif // FILE_UTIL_H